package com.hcrazy.manchester.app.services;

import java.util.List;

import com.hcrazy.manchester.app.jdbc.AdvertDAO;
import com.hcrazy.manchester.app.pojo.Advert;
import com.hcrazy.manchester.app.utils.Constant;

public class AdvertService {

	private AdvertDAO advertDAO;
	
	public AdvertDAO getAdvertDAO() {
		return advertDAO;
	}

	public void setAdvertDAO(AdvertDAO advertDAO) {
		this.advertDAO = advertDAO;
	}
	
	public List<Advert> getAdverts(int type) throws Exception {
		return advertDAO.getAdvert(type);
	}
	
	/**
	 * 获取开机广告
	 * @return
	 * @throws Exception
	 */
	public List<Advert> getAdvertStart() throws Exception {
		return getAdverts(Constant.ADVERT_START);
	}
	
	/**
	 * 获取首页广告
	 * @return
	 * @throws Exception
	 */
	public List<Advert> getAdvertIndex() throws Exception{
		return getAdverts(Constant.ADVERT_INDEX);
	}
	
	/**
	 * 获取列表页广告
	 * @param moduleType
	 * @return
	 * @throws Exception
	 */
	public List<Advert> getAdvertList(int moduleType) throws Exception {
		if(moduleType == Constant.COMM_BOOK_INFO_MODULE){
			moduleType = Constant.COMM_TICKET_INFO_MODULE;
		}
		return advertDAO.getAdvertList(moduleType);
	}
}
